import {doCustomTimes} from "@/lib/tools";
import Mock from 'mockjs';

export const getTableData = () => {
	const template = {
		name: '@name',
		'age|18-25': 0,
		email: '@email'
	};
	const arr = [];
	doCustomTimes(5, () => arr.push(Mock.mock(template)));
	return arr;
};

export const getFileList = () => {
	const template = {
		'name|5': '@cword', // 中文，包含5个汉字
		'create_time': '@datetime',
		'folder_id|1-5': 0, // 文件夹的id，1-5的随机数
		'id|+1': 10000 // 文件id，id每次+1
	};
	const arr = [];
	doCustomTimes(10, () => arr.push(Mock.mock(template)));
	return arr;
};

export const getFolderList = () => {
	const template1 = {
		'name|1': '@word',// 文件夹名称，英文
		'creat_time': '@datetime',
		'folder_id': 0,// 文件夹id，包含嵌套的文件夹id
		'id|+1': 1// 自身id
	};
	const template2 = {
		'name|1': '@word',
		'creat_time': '@datetime',
		'folder_id|+1': 1,
		'id|+1': 4
	};

	const arr = [];
	doCustomTimes(3, () => arr.push(Mock.mock(template1)));
	doCustomTimes(2, () => arr.push(Mock.mock(template2)));
	return arr;
};

export const getUploadFileList = () => {
	const template = {
		'index|+1': 0,
		'id|+1': 1,
		'key|1-10000': 1,
		'file_name': '@word',
		'file_type|1': ['text', 'download'],
		'file_size': '@natural(1, 100)',
		'createAt': '@datetime',
		'storage_time|1': ['', '@natural(1, 5)']
	};
	const arr = [];
	doCustomTimes(5, () => arr.push(Mock.mock(template)));
	return arr;
}
